<link rel="stylesheet" href="/upload/zx/css/jquery-ui.css" />
<script type="text/javascript" src="/upload/zx/js/jquery/jquery-ui.js"></script>
<script type="text/javascript">

    function get_activity_list (manager_uid)
    {
		$.get('/widget/ajax_activity_list/'+manager_uid,
			{
			},
			function (o) {
				if(o){
					var opt='<option value="">全部活动</option>';
					for(i=0; i<o.length; i++)
					{
						var selected='';
                        /*
						if(county == o[i].id)
						{
							selected = 'selected="selected"';
						}
                        */
						opt += '<option value="' + o[i].id + '" ' + selected + '>' + o[i].name + '</option>';
					}
					$('#select_activity option').remove();
					$('#select_activity').append(opt);

					$('#select_channel option').remove();
				}
			},
			'json'
		);
	}

    function get_channel_list (activity_id)
    {
        today = new Date();
		$.get('/widget/ajax_channel_list/'+activity_id +'?t=' + today.getTime(),
			{
			},
			function (o) {
				if(o){
					var opt='<option value="">全部渠道</option>';
					for(i=0; i<o.length; i++)
					{
						var selected='';
                        /*
						if(county == o[i].id)
						{
							selected = 'selected="selected"';
						}
                        */
						opt += '<option value="' + o[i].key + '" ' + selected + '>' + o[i].name + '</option>';
					}
					$('#select_channel option').remove();
					$('#select_channel').append(opt);

                    var chns = $('#select_channel option');
                    var sources = [];
                    for (var x = 0; x < chns.length; ++x)
                    {
                        var v = $(chns[x]).val();
                        var t = $(chns[x]).text();
                        sources[sources.length] = {label: t, value : v};
                    }

                    $('#keyword').autocomplete('option', 'source', sources);
				}
			},
			'json'
		);
	}

    $(function () {
        var chns = $('#select_channel option');
        var sources = [];
        for (var x = 0; x < chns.length; ++x)
        {
            var v = $(chns[x]).val();
            var t = $(chns[x]).text();
            sources[sources.length] = {label: t, value : v};
        }

        $('#keyword').autocomplete({ 
            source : sources,
            select : function(e, ui) { 
                var v = ui.item.value;
                $('#select_channel').attr('value', v);
            },
        }); 

    });
</script>

<form method='GET' action='data'>
    <span class="fw" style="font-family:'黑体'">&nbsp;</span>从<input type="text" value="<{$request.start_date}>" id="date1" name='start_date' />至
	<input type="text" value="<{$request.end_date}>" id="date2" name='end_date'/>

    <{if $global_site_type == 'manager' and ($user_info.role_id == 'commonmanager' or $user_info.role_id == 'supermanager' or $user_info.role_id == 'financial') }>
	    <select id="select_manager" class="spread_tab" name='manager_id' onchange="get_activity_list(this.value)">
            <option value="0">项目主管</option>
	    <{foreach from=$managers item='v'}>
	        <option value ='<{$v.uid}>' <{if $v.uid == $request.manager_id}>selected<{/if}>><{if $v.realname}><{$v.realname}><{else}><{$v.nickname}><{/if}></option>
        <{/foreach}>
	    </select>
    <{/if}>
            
	<select id="select_activity" class="spread_tab" name='activity_id' onchange="get_channel_list(this.value)">
	<{foreach from=$activities item='v'}>
	    <option value ='<{$v.id}>' <{if $v.id==$request.activity_id}>selected<{/if}> ><{$v.name}></option>
    <{/foreach}>
	</select>

	<select id="select_channel" class="spread_tab" name='channel_key'>
	<{foreach from=$channels item='v'}>
	    <option value ='<{$v.unique_key}>' <{if $v.unique_key==$request.channel_key}>selected<{/if}> ><{$v.name}></option>
	<{/foreach}>
	</select>
	
    <input type="text" id="keyword" name="keyword" value="">
	<input class="effect-update" type='submit' value='查询'>
</form>
